<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
    <title>crosshairs</title>
    <!--[if IE]>
    <script type="text/javascript" src="../excanvas.js"></script>
    <![endif]-->
    <!--
    For production (minified) code, use:
    <script type="text/javascript" src="dygraph-combined.js"></script>
    -->
    <script type="text/javascript" src="../dygraph-dev.js"></script>

    <script type="text/javascript" src="data.js"></script>
    <style type="text/css">
      .line {
        visibility: hidden;
        background-color: black;
        position: absolute;
        pointer-events: none;  /* let mouse events fall through to the chart */
      }
      .yline {
        width: 100%;
        height: 1px;
      }
      .xline {
        height: 100%;
        width: 1px;
      }
    </style>
  </head>
  <body>
    <p>Hover, click and zoom to test the callbacks:</p>
    <div id="div_g" style="width:600px; height:300px; position:relative;">
    </div>

    <script type="text/javascript">
      var lines = [];
      var xline;
      g = new Dygraph(
            document.getElementById("div_g"),
            NoisyData, {
              rollPeriod: 7,
              showRoller: true,
              errorBars: true,

              highlightCallback: function(e, x, pts) {
                for (var i = 0; i < pts.length; i++) {
                  var y = pts[i].canvasy;
                  lines[i].style.visibility = "visible";
                  lines[i].style.top = y + "px";
                  if (i == 0) xline.style.left = pts[i].canvasx + "px";
                }
                xline.style.visibility = "visible";
              },

              unhighlightCallback: function(e) {
                for (var i = 0; i < 2; i++) {
                  lines[i].style.visibility = "hidden";
                }
                xline.style.visibility = "hidden";
              }
            }
          );

      for (var i = 0; i < 2; i++) {
        var line = document.createElement("div");
        line.className = "line yline";
        document.getElementById("div_g").appendChild(line);
        lines.push(line);
      }

      xline = document.createElement("div");
      xline.className = "line xline";
      xline.style.top = "0px";
      document.getElementById("div_g").appendChild(xline);
    </script>
  </body>
</html>
